#include <vector>
#include <iostream>

#include "../utils.h"

using namespace std;

template <class T>
void print_vector_size(const vector<T>& v, const char* opt_message="")
{
    cout << opt_message << endl;
    cout << "size() " << v.size() << endl;
    cout << "capacity() " << v.capacity() << endl;
    cout << "max_size() " << v.max_size() << endl;    
}

template <class T>
void print_vector_elements(const vector<T>& v, 
                           const char* opt_message="",
                           const char seperator=' ')
{
    print_elements<vector<T> >(v, opt_message, seperator);
}

void study_vector_access_elements()
{

}

void study_vector_initialization()
{
    vector<int> v1;  
    print_vector_size<int>(v1,"size of empty vector");
    
    vector<int> v2(5); 
    print_vector_elements<int>(v2, "vector with 5 default constructed elements");
    
    vector<int> v3(5,10);
    print_vector_elements<int>(v3, "initialize all elements in vector with value");
    
    vector<int> v4(v3);
    print_vector_elements<int>(v3, "initialize vector with another vector");
    
    vector<int> v5(v4.begin(), v4.end());
    print_vector_elements<int>(v3, "initialize vector with part of othert vector");
    
    int array[10]={1,2,3,4,5,6,7,8,9,10};
    vector<int> v6(array, array+sizeof(array)/sizeof(array[0]));
    print_vector_elements<int>(v6, "initialize vector with array");
}

void study_vector_size()
{
    vector<int> v(5);   //initial
    print_vector_size<int>(v);    
    
    v.reserve(8);       //increase the capacity
    print_vector_size<int>(v);
    
    for (int i=0; i<10; ++i) { v.push_back(i);}    //add data
    print_vector_size<int>(v);
    
    vector<int>(v).swap(v); //shrink the capacity.
    print_vector_size<int>(v);
}

int Study_vector(int argc, char** argv)
{
	int rc=0;
    //study_vector_size();
    study_vector_initialization();

	return rc;
}
